
#ifndef __CELOG_DBGMSG_H__
#define __CELOG_DBGMSG_H__

#include <celog.h>

#ifndef ZONE_CELOG
#define ZONE_CELOG (1<<31)
#endif

#ifdef CELOG_DBGMSG_KNL

extern DWORD dwCeLogLargeBuf;
extern DWORD dwCeLogSmallBuf;


void SC_CeLogData(BOOL fTimeStamp, WORD wID, VOID *pData, WORD wLen,
                  DWORD dwZoneUser, DWORD dwZoneCE, WORD wFlag, BOOL fFlagged);

#ifdef OALMSGS
#undef OALMSGS
#define OALMSGS(cond, printf_exp) \
    ( (void)(((cond) ? \
        ( ((cond)&(ZONE_CELOG)) ? (CeLogMsg printf_exp), 1 : (OALLogSerial printf_exp), 1) : 0) ) )

#endif	//ifdef OALMSGS

#ifdef OALMSG
#undef OALMSG
#define OALMSG(cond, printf_exp) \
    ( (void)(((cond) ? \
        ( ((cond)&(ZONE_CELOG)) ? (CeLogMsg printf_exp), 1 : (OALLog printf_exp), 1) : 0) ) )

#endif	//ifdef OALMSG


__inline static
void KnlDbgCeLogMsg (LPCTSTR szFormat,... )
{
	TCHAR szBuffer[MAX_PATH];
	int iLen;
	
	va_list pArgs; 
	va_start(pArgs, szFormat);
	iLen=NKwvsprintfW(szBuffer, szFormat, pArgs, sizeof(szBuffer)/sizeof(TCHAR));
	va_end(pArgs);

    if (iLen >= 0) {
        szBuffer[iLen] = 0;
		SC_CeLogData(TRUE,CELID_RAW_WCHAR,szBuffer,(WORD)((iLen + 1)*sizeof(TCHAR)),
					CELZONE_ALWAYSON, 0, 0, FALSE);
    }
};


#else	//#ifdef CELOG_DBGMSG_KNL


#ifdef DEBUGMSG
#undef DEBUGMSG
#define DEBUGMSG(cond, printf_exp) \
    ( (void)(((cond) ? \
        ( ((cond)&(ZONE_CELOG)) ? (CeLogMsg printf_exp), 1 : (NKDbgPrintfW printf_exp), 1) : 0) ) )

#endif	//ifdef DEBUGMSG

#ifdef RETAILMSG
#undef RETAILMSG
#define RETAILMSG(cond, printf_exp) \
    ( (void)(((cond) ? \
        ( ((cond)&(ZONE_CELOG)) ? (CeLogMsg printf_exp), 1 : (NKDbgPrintfW printf_exp), 1) : 0) ) )

#endif	//ifdef RETAILMSG


#endif	//#ifdef CELOG_DBGMSG_KNL


#endif	//#ifndef __CELOG_DBGMSG_H__
